package com.tulele.vtool.task.async;

import com.tulele.vtool.model.UserShareArticleInfo;
import com.tulele.vtool.service.IUserShareArticleInfoService;
import com.tulele.vtool.utils.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class AddUserShareArticleInfoAsyncTask {

    @Autowired
    private IUserShareArticleInfoService userShareArticleInfoService;

    @Async
    public void addUserShareArticleInfo(Integer userId, Integer articleId, Integer articleCategory) {

        UserShareArticleInfo userShareArticleInfo = new UserShareArticleInfo();
        userShareArticleInfo.setUserId(userId);
        userShareArticleInfo.setArticleId(articleId);
        userShareArticleInfo.setArticleCategory(articleCategory);
        userShareArticleInfo.setCreateTime(DateUtil.getCurDate());

        userShareArticleInfoService.recordUserShareArticleInfo(userShareArticleInfo);


    }

    @Async
    public void deleteByUserIdAndArticleId(Integer userId, Integer articleId) {
        userShareArticleInfoService.deleteByUserIdAndArticleId(userId, articleId);
    }

}
